package leecode.stringAndArray.Array;

import java.util.Arrays;

public class CenterIndexOfArray {
    public static void main(String[] args) {
        int[] array=new int[]{1,7,3,6,5,6};
        for(int i=0; i<array.length; i++){
            int before=0;
            int after=0;
            for(int j=0; j<i; j++){
                before+=array[j];
            }
            for(int z=i+1; z<array.length; z++){
                after+=array[z];
            }
            if(before==after){
                System.out.println("找到了"+i);
            }
        }
        System.out.println("没找到");;
    }

    public static int solution(int[] nums){
        int total = Arrays.stream(nums).sum();
        int sum=0;
        for (int i = 0; i < nums.length; i++) {
            if(sum*2 +nums[i]==total){
                return i;
            }
            sum+=nums[i];
        }
        return -1;
    }
}
